home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 19.zip
/
BS1 part 19
/
how to learn assembler.adf
/
CH4
/
4_3_1bin-hex.asm
< prev
next >
Wrap
Assembly Source File
|
1988-02-25
|
1KB
|
33 lines
;(4.3.1) bin-hex
; .... ;your program
lea buffer,a0 ; Pointer to buffer
move #$4A,d1 ; Byte to be converted
bsr byte ; and convert
rts
; ... ;the rest of your program
byte:
move d1,d2 ; Move value into D2
lsr #4,d2 ; Move upper nibble into lower nibble
bsr nibble ; Convert D2
move.b d2,(a0)+ ; Put character in buffer
move d1,d2 ; Value in D2
bsr nibble ; Convert lower nibble
move.b d2,(a0)+ ; and put it in buffer
rts ; Done converting
nibble:
and #$0F,d2 ; Just keep low byte
add #$30,d2 ; Add $30
cmp #$3A,d2 ; Was it a digit?
bcs ok ; Yes, done
add #7,d2 ; Else add 7
ok:
rts ; Bye-bye
buffer:
DS.B 9 ; Enough space for 8 hex digits and a null byte
end